<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
    // echo date('Y-m-d H:i:s',time());

    //获取配置文件信息
    //echo Config::get('app.timezone');
   // echo Config::get('app.url');

    //设置
   // Config::set('app.timezone','UTC');

   // echo Config::get('app.timezone');

    //echo Config::get('app.webname');

    //获取环境配置
    //echo env('DB_CONNECTION');

    //www.lamp151.com/index.php?love=ee


});


//路由的基本使用
Route::get('love',function(){

	echo 'hello world';
});

Route::post('form',function(){

	echo '这是以post方式进行请求';
});



//带参数
Route::get('like/{id}',function($id){

	echo $id;
})->where('id','\d+');

//带多个参数
Route::get('demo/{name}={id}',function($name,$id){

	echo $name;
	echo $id;
})->where('name','[a-zA-Z]+')
  ->where('id','\d+');

  //路由别名
 Route::get('home/user/add',['as'=>'users',function(){

  		echo route('users');
  		//echo 'hhhhhh';

  }]);
 //路由组的设置

 Route::group(['middleware'=>'login'],function(){
 	//这是前台的用户添加
 	Route::get('home/user/add',function(){

 		echo '这是前台的用户添加';
 	});

 	//这是后台的用户添加
 	Route::get('admin/user/add',function(){

 		echo '这是后台的用户添加';
 	});

 });

 //404
 Route::get('as',function(){

 	abort('404');
});


Route::get('ajax',function(){

    return view('ajax');
});

Route::post('pro',function(){

    echo '以post的方式进行请求';
});



 //中间件
 Route::get('login',function(){

 	echo '这是登录页面';
 });

 //
 Route::get('middle',function(){

 	echo '这是测试信息';
 })->middleware('login');

 Route::get('ware',['middleware'=>'login'],function(){

 	echo 'jjjjjjj';
 });


 //控制器的操作
 Route::get('user/add','UserController@add');
 Route::get('user/delete/{id}','UserController@delete')->where('id','\d+');
 Route::post('user/insert','UserController@insert');

//别名
 Route::get('/user/edit',[
 	'as' => 'users',
 	'uses'=>'Usercontroller@edit'

 	])->middleware('login');

 //隐式控制器
 Route::controller('goods','GoodsController');


//资源控制器
Route::resource('test','TestController');

Route::get('test',function(){

  return view('form');
});


Route::get('lib',function(){

  // return '张舫';

  // return response()->json(['one'=>'hello','two'=>'world','three'=>'love']);

  return response()->download('./img/www.jpg');
});



Route::controller('pass','PassController');


Route::controller('news','NewsController');

